


************************************************************************************************************************************************

***AUSTRIA, 2009 

****Refrigerators

clear all

use "Estimation Sample.dta"
keep 			if country=="Austria"
keep 			if year==2009
keep 			if category=="refrigerator"

by id, sort: 	egen mean_price=mean(price) if year==2009 & month<=5
sum mean_price

encode nofrostsys, 		gen(nofrost)
encode construction, 	gen(constr)
encode main_type, 		gen(type)


collapse (mean) nofrost type constr mean_price, by(id year treataf)

cem nofrost type constr mean_price(200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600) , treatment(treataf) k2k


keep id cem_matched

merge m:m id using "Estimation Sample.dta"
drop _merge

by id, sort: egen sumcema9=sum(cem_matched)
drop cem_matched


save "Estimation Sample.dta", replace


****Freezers

clear all
use "Estimation Sample.dta"

keep 			if country=="Austria"
keep 			if year==2009
keep 			if category=="freezer"

by id, sort: 	egen mean_price=mean(price) if year==2009 & month<=5
sum mean_price

encode nofrostsys, 		gen(nofrost)
encode construction, 	gen(constr)
encode type_freezer,	gen(typef)

collapse (mean) nofrost typef constr mean_price, by(id year treataf)

cem nofrost typef constr mean_price(200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600), treatment(treataf) k2k

keep id cem_matched

merge m:m id using "Estimation Sample.dta"

drop _merge 
by id, sort: egen sumcemfa9=sum(cem_matched)
drop cem_matched

gen 	controlma9=0
replace controlma9=1 if (sumcema9>0 & treataf==0)|(sumcemfa9>0 & treataf==0)

codebook id if controlma9==1

save "Estimation Sample.dta", replace




************************************************************************************************************************************************
***AUSTRIA, 2010 

****Refrigerators
clear all

use "Estimation Sample.dta"


keep 			if country=="Austria"
keep 			if year==2010
keep 			if category=="refrigerator"

by id, sort: 	egen mean_price=mean(price) if year==2010 & month<=5

encode nofrostsys, 		gen(nofrost)
encode construction, 	gen(constr)
encode main_type, 		gen(type)

collapse (mean) nofrost type constr mean_price, by(id year treataf)


cem nofrost type constr mean_price(200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600), treatment(treataf) k2k

keep id cem_matched

merge m:m id using "Estimation Sample.dta"

drop _merge

by id, sort: egen sumcema10=sum(cem_matched)

drop cem_matched

save "Estimation Sample.dta", replace


****Freezers
clear all

use "Estimation Sample.dta"


keep 			if country=="Austria"
keep 			if year==2010
keep 			if category=="freezer"

by id, sort: 	egen mean_price=mean(price) if year==2010 & month<=5


encode nofrostsys, 		gen(nofrost)
encode construction, 	gen(constr)
encode type_freezer,	gen(typef)

collapse (mean) nofrost typef constr mean_price, by(id year treataf)

cem nofrost typef constr mean_price(200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600), treatment(treataf) k2k


keep id cem_matched

merge m:m id using "Estimation Sample.dta"
drop _merge

by id, sort: egen sumcemfa10=sum(cem_matched)
drop cem_matched


gen 	controlma10=0
replace controlma10=1 if (sumcema10>0 & treataf==0)|(sumcemfa10>0 & treataf==0)

codebook id if controlma10==1


save "Estimation Sample.dta", replace



************************************************************************************************************************************************
***HUNGARY, 2016

clear all

****Refrigerators

use "Estimation Sample.dta" 

keep 			if country=="Hungary"
keep 			if year==2016
keep 			if category=="refrigerator"

by id, sort: 	egen mean_price=mean(price_eur) if year==2016 & month<=5
sum mean_price

encode nofrostsys, 		gen(nofrost)
encode construction, 	gen(constr)
encode main_type, 		gen(type)

collapse (mean) nofrost type constr mean_price, by(year id treathf) 

cem nofrost type constr mean_price(200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600), treatment(treathf) k2k

keep id cem_matched

merge m:m id using "Estimation Sample.dta" 
drop _merge

by id, sort: egen sumcemh16=sum(cem_matched)
drop cem_matched


save "Estimation Sample.dta", replace


****Freezers

clear all

use "Estimation Sample.dta" 


keep 			if country=="Hungary"
keep 			if year==2016
keep 			if category=="freezer"

by id, sort: 	egen mean_price=mean(price_eur) if year==2016 & month<=5
sum mean_price

encode nofrostsys, 		gen(nofrost)
encode construction, 	gen(constr)
encode type_freezer,	gen(typef)

collapse (mean) nofrost typef constr mean_price, by(year id treathf) 

cem nofrost typef constr mean_price(200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600), treatment(treathf) k2k


keep id cem_matched

merge m:m id using "Estimation Sample.dta"
drop _merge
by id, sort: egen sumcemfh16=sum(cem_matched)

drop cem_matched


gen 		controlmh16=0
replace 	controlmh16=1 		if (sumcemh16>0 & treathf==0)|(sumcemfh16>0 & treathf==0)
codebook 	id 					if controlmh16==1


save "Estimation Sample.dta", replace





************************************************************************************************************************************************
***AUSTRIA, 2010, WM
clear all
use "Estimation Sample.dta" 
 

keep 			if country=="Austria"
keep 			if (year==2009|year==2010)
keep 			if category=="washing machine"

by id, sort: 	egen mean_price=mean(price) if (year==2009 & month>=9|year==2010 & month<=1)
sum mean_price 	
keep 			if year==2010

encode type_wm, 		gen(type)
destring loading_kg, replace

collapse (mean) type loading_kg mean_price, by(year id treata)

cem type loading_kg mean_price(200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600), treatment(treata) k2k

keep id cem_matched

merge m:m id using "Estimation Sample.dta"
drop _merge

by id, sort: egen sumcemaw=sum(cem_matched)

drop cem_matched


gen 		controlmaw=0
replace 	controlmaw=1 		if (sumcemaw>0 & treata==0)
codebook 	id 					if controlmaw==1



save "Estimation Sample.dta", replace




************************************************************************************************************************************************
***HUNGARY, 2015, WM

clear all

use "Estimation Sample.dta", 

keep 			if country=="Hungary"
keep 			if year==2015
keep 			if category=="washing machine"

by id, sort: 	egen mean_price=mean(price_eur) if year==2015 & month<=5


encode type_wm, 		gen(type)
destring loading_kg, 	replace


collapse (mean) type loading_kg mean_price, by(year id treath)
cem type loading_kg mean_price(200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600), treatment(treath) k2k

keep id cem_matched

merge m:m id using "Estimation Sample.dta"
drop _merge

by id, sort: egen sumcemh15=sum(cem_matched)

drop cem_matched


gen 		controlmh15=0
replace 	controlmh15=1 		if (sumcemh15>0 & treath==0)
codebook 	id 					if controlmh15==1


save "Estimation Sample.dta", replace



************************************************************************************************************************************************
***CROATIA, 2015, WM 
clear all

use "Estimation Sample.dta" 

keep 			if country=="Croatia"
keep 			if (year==2014|year==2015)
keep 			if category=="washing machine"

by id, sort: 	egen mean_price=mean(price_eur) if (year==2014& month>=11|year==2015 & month<=3)
sum mean_price 	
keep 			if year==2015

encode type_wm, 		gen(type)
destring loading_kg, replace

collapse type loading_kg mean_price, by(year id treatc)
cem type loading_kg mean_price(200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600), treatment(treatc) k2k

keep id cem_matched

merge m:m id using "Estimation Sample.dta"
drop _merge

by id, sort: egen sumcemc=sum(cem_matched)

drop cem_matched

gen 		controlmc=0
replace 	controlmc=1 		if (sumcemc>0 & treatc==0)
codebook 	id 					if controlmc==1


save "Estimation Sample.dta", replace



drop if treataf==1
replace treataf=1 if controlma9==1 	& country=="Austria"
replace treataf=1 if controlma10==1 & country=="Austria"

drop if treata==1
replace treata=1  if controlmaw==1  & country=="Austria"

drop if treathf==1
replace treathf=1 if controlmh16==1 & country=="Hungary"

drop if treath==1
replace treath=1  if controlmh15==1 & country=="Hungary"

drop if treatc==1
replace treatc=1  if controlmc==1   & country=="Croatia"

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	

***CLOSE SUBSTITUTES, AUSTRIA, 2009
preserve

drop if category=="washing machine"
egen cmt=group(country month treataf)

xtset id2

reghdfe dlogunits i.presub3af9##ib1.treataf i.presub2af9##ib1.treataf i.presub1af9##ib1.treataf i.sub1af9##ib1.treataf i.sub2af9##ib1.treataf i.sub3af9##ib1.treataf i.sub4af9##ib1.treataf i.postsub1af9##ib1.treataf i.postsub2af9##ib1.treataf i.postsub3af9##ib1.treataf  mage mage2 , absorb(id2 cmt) cluster(id) 
est store close1

esttab   close1 , se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) keep(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) 

esttab   close1  using "c1.tex", replace  se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) keep(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) 

restore

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
***CLOSE SUBSTITUTES, AUSTRIA, 2010

preserve

drop if category=="washing machine"
egen cmt=group(country month treataf)
 
xtset id2
 
reghdfe dlogunits i.presub3af10##ib1.treataf i.presub2af10##ib1.treataf i.presub1af10##ib1.treataf i.sub1af10##ib1.treataf i.sub2af10##ib1.treataf i.sub3af10##ib1.treataf i.postsub1af10##ib1.treataf i.postsub2af10##ib1.treataf i.postsub3af10##ib1.treataf  mage mage2 , absorb(id2 cmt) cluster(id)
est store close2

esttab   close2, se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) keep(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10)

esttab   close2  using "c2.tex", replace  se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10 ) keep(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) 

restore

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
***CLOSE SUBSTITUTES, AUSTRIA, 2010, WM

preserve

keep if category=="washing machine"

egen cmt=group(country month treata)

xtset id2

reghdfe dlogunits i.presub3a##ib1.treata i.presub2a##ib1.treata i.presub1a##ib1.treata i.sub1a##ib1.treata i.sub2a##ib1.treata i.postsub1a##ib1.treata i.postsub2a##ib1.treata i.postsub3a##ib1.treata  mage mage2 , absorb(id2 cmt) cluster(id) 
est store close3

esttab   close3, se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a) keep(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a) 

esttab   close3  using "c3.tex", replace se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a) keep(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a)  

restore


*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
***CLOSE SUBSTITUTES, HUNGARY, 2015

preserve

keep if category=="washing machine"

egen cmt=group(country month treath)

xtset id2


reghdfe dlogunits i.presub3h##ib1.treath i.presub2h##ib1.treath i.presub1h##ib1.treath i.sub1h##ib1.treath i.sub2h##ib1.treath i.sub3h##ib1.treath i.sub4h##ib1.treath i.postsub1h##ib1.treath i.postsub2h##ib1.treath i.postsub3h##ib1.treath mage mage2  if country!="Croatia", absorb(id2 cmt) cluster(id) 
est store close4

esttab   close4 , se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3h 1.presub2h 1.presub1h 1.sub1h 1.sub2h 1.sub3h 1.sub4h 1.postsub1h 1.postsub2h 1.postsub3h) keep(1.presub3h 1.presub2h 1.presub1h 1.sub1h 1.sub2h 1.sub3h 1.sub4h 1.postsub1h 1.postsub2h 1.postsub3h ) 

esttab   close4  using "c4.tex" ,replace  se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3h 1.presub2h 1.presub1h 1.sub1h 1.sub2h 1.sub3h 1.sub4h 1.postsub1h 1.postsub2h 1.postsub3h) keep(1.presub3h 1.presub2h 1.presub1h 1.sub1h 1.sub2h 1.sub3h 1.sub4h 1.postsub1h 1.postsub2h 1.postsub3h) 


restore

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
***CLOSE SUBSTITUTES, HUNGARY, 2016

preserve
drop if category=="washing machine"
egen cmt=group(country month treathf)

xtset id2

reghdfe dlogunits i.presub3hf##ib1.treathf i.presub2hf##ib1.treathf i.presub1hf##ib1.treathf i.sub1hf##ib1.treathf i.sub2hf##ib1.treathf i.sub3hf##ib1.treathf i.sub4hf##ib1.treathf i.postsub1hf##ib1.treathf  mage mage2 , absorb(id2 cmt) cluster(id)
est store close5

esttab   close5 , se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3hf 1.presub2hf 1.presub1hf 1.sub1hf 1.sub2hf 1.sub3hf 1.sub4hf 1.postsub1hf) keep(1.presub3hf 1.presub2hf 1.presub1hf 1.sub1hf 1.sub2hf 1.sub3hf 1.sub4hf 1.postsub1hf) 

esttab   close5  using "c5.tex" ,replace  se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3hf 1.presub2hf 1.presub1hf 1.sub1hf 1.sub2hf 1.sub3hf 1.sub4hf 1.postsub1hf) keep(1.presub3hf 1.presub2hf 1.presub1hf 1.sub1hf 1.sub2hf 1.sub3hf 1.sub4hf 1.postsub1hf) 

restore

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
***CLOSE SUBSTITUTES, CROATIA, 2015
preserve
keep if category=="washing machine"

egen cmt=group(country month treatc)

xtset id2


reghdfe dlogunits i.presub3c##ib1.treatc i.presub2c##ib1.treatc i.presub1c##ib1.treatc i.sub1c##ib1.treatc i.postsub1c##ib1.treatc i.postsub2c##ib1.treatc i.postsub3c##ib1.treatc i.postsub4c##ib1.treatc i.postsub5c##ib1.treatc i.postsub6c##ib1.treatc  i.postsub7c##ib1.treatc mage mage2  if country!="Hungary" , absorb (id2 cmt) cluster(id)
est store close6



esttab   close6 , se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3c 1.presub2c 1.presub1c 1.sub1c 1.postsub1c 1.postsub2c 1.postsub3c 1.postsub4c 1.postsub5c 1.postsub6c 1.postsub7c) keep(1.presub3c 1.presub2c 1.presub1c 1.sub1c 1.postsub1c 1.postsub2c 1.postsub3c 1.postsub4c 1.postsub5c 1.postsub6c 1.postsub7c) 

esttab   close6  using "c6.tex" ,replace  se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3c 1.presub2c 1.presub1c 1.sub1c 1.postsub1c 1.postsub2c 1.postsub3c 1.postsub4c 1.postsub5c 1.postsub6c 1.postsub7c) keep(1.presub3c 1.presub2c 1.presub1c 1.sub1c 1.postsub1c 1.postsub2c 1.postsub3c 1.postsub4c 1.postsub5c 1.postsub6c 1.postsub7c) 


restore


 
